import * as resume from '@/api/resume.js'
import Resume from '@/components/resume/index.vue'
import empty from '@/components/empty/index.vue'
import Position from '@/components/position/index.vue'
export default {
	components: {
		Resume,
		Position,
		empty
	},
	data() {
		return {
			token: '',
			Type: '',
			Form: {
				"name": "请登录",
				"head": "/static/user/head-pimg.png",
			},
			experience: [], //案例展示
			educate:[],//教育经历
			zwform:{
				page:1,
				state:0
			},
			total:-1,
			zwList:[],
			tableList:[
				{
					title:'全部',
					state:0
				},
				{
					title:'需求中',
					state:1
				},
				{
					title:'已关闭',
					state:2
				},
				{
					title:'审核中',
					state:3
				},
				{
					title:'已拒绝',
					state:4
				}
			],//table列表
			tableIndex:0,//当前选择
		}
	},
	mounted() {


	},
	onShow() {
		this.token = uni.getStorageSync('token')
		this.Type = uni.getStorageSync('Type')
		if(uni.getStorageSync('token')){
			if(this.Type==0){
				this.getMemberResumeInfo()
				this.getMemberResumeExperienceList()
				this.getMemberResumeEducateList()
			}
			else{
				this.getMemberPositionList()
			}
		}
	},
	onLoad(){
		uni.$on('Type',(data)=>{
			this.Type = uni.getStorageSync('Type')
		})
		if(uni.getStorageSync("Type")==0){
			uni.setNavigationBarTitle({
				title: '发布接单'
			});
		}
		else{
			uni.setNavigationBarTitle({
				title: '发布需求'
			});
		}
	},
	onReachBottom() {
		if(this.Type==1){
			this.zwform.page = this.zwform.page+1
			this.getMemberPositionList()
		}
	},
	onPullDownRefresh(){
		if(this.Type==1){
			this.zwform.page = 1
			this.getMemberPositionList()
		}
	},
	methods: {
		tableChange(item,index){
			this.tableIndex = index
			this.zwform.state = item.state
			this.zwform.page = 1
			this.zwList = []
			this.getMemberPositionList()
		},
		//查询接单信息
		getMemberResumeInfo() {
			resume.getMemberResumeInfo().then(res => {
				this.Form = res.data
				
			})
		},
		//查询案例展示
		getMemberResumeExperienceList() {
			resume.getMemberResumeExperienceList().then(res => {
				this.experience = res.data
			})
		},
		//查询教育经历
		getMemberResumeEducateList() {
			resume.getMemberResumeEducateList().then(res => {
				this.educate = res.data
			})
		},
		//查询需求列表
		getMemberPositionList(page){
			if(page) {
				this.zwform.page = page
			}
			resume.getMemberPositionList(this.zwform).then(res=>{
				if(this.zwform.page == 1) {
					this.zwList = res.data.data
					this.total = res.data.total
				} else {
					this.zwList.push(...res.data.data)
					this.total = res.data.total
				}
			})
		}
	}
}
